package com.bhs.sansonglogistics.ui.wallet;

import android.content.Intent;

import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.base.BaseActivity;
import com.bhs.sansonglogistics.utils.LogUtils;
import com.bhs.sansonglogistics.utils.StatusBarUtil;
import com.bhs.sansonglogistics.view.ViewFinder;
import com.shouzhong.bankcard.BankCardInfoBean;
import com.shouzhong.scanner.Callback;
import com.shouzhong.scanner.Result;
import com.shouzhong.scanner.ScannerUtils;
import com.shouzhong.scanner.ScannerView;

/**
 * 银行卡扫描页
 */
public class ScanActivity extends BaseActivity {

    private ScannerView scannerView;

    @Override
    public int initLayout() {
        return R.layout.activity_scan;
    }

    @Override
    public void initView() {
        StatusBarUtil.setTranslucentStatus(this, true);
        StatusBarUtil.setStatusBarDarkTheme(this, true);
        scannerView = findViewById(R.id.sv);
    }

    @Override
    public void initData() {
        scannerView.setViewFinder(new ViewFinder(this));
        scannerView.setEnableBankCard(true);

        scannerView.setCallback(new Callback() {
            @Override
            public void result(Result result) {
                Intent i = new Intent();
                i.putExtra("data", result.data);
                setResult(3, i);
                finish();
                scannerView.restartPreviewAfterDelay(2000);
            }
        });

    }

    @Override
    protected void onResume() {
        super.onResume();
        scannerView.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        scannerView.onPause();
    }
}